﻿using System.Collections.Generic;

namespace BattleFury.Lib.Collections
{
	public class ContentDictionary<TKey, TValue>
	{
		protected readonly IList<TKey> Keys = new List<TKey>();
		protected readonly IList<TValue> Values = new List<TValue>();


		public int Count
		{
			get { return Values.Count; }
		}

		public bool IsReadOnly
		{
			get { return Values.IsReadOnly; }
		}

		public TValue this[TKey key]
		{
			get { return Values[IndexOf(key)]; }
			set { Values[IndexOf(key)] = value; }
		}

		public TValue this[int index]
		{
			get { return Values[index]; }
			set { Values[index] = value; }
		}

		public ContentDictionary()
		{
			
		}


		public IEnumerator<TValue> GetEnumerator()
		{
			return Values.GetEnumerator();
		}

		public virtual TValue Add(TKey key, TValue item)
		{
			Keys.Add(key);
			Values.Add(item);
			return item;
		}

		public void Clear()
		{
			Values.Clear();
			Keys.Clear();
		}

		public bool Contains(TValue item)
		{
			return Values.Contains(item);
		}

		public bool ContainsKey(TKey key)
		{
			return Keys.Contains(key);
		}

		public bool Remove(TValue item)
		{
			Keys.RemoveAt(Values.IndexOf(item));
			return Values.Remove(item);
		}

		public int IndexOf(TValue item)
		{
			return Values.IndexOf(item);
		}

		public int IndexOf(TKey key)
		{
			return Keys.IndexOf(key);
		}

		public void RemoveAt(int index)
		{
			Keys.RemoveAt(index);
			Values.RemoveAt(index);
		}
	}
}